Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CodeStyle][task 10] enable ruff B017 rule in python/paddle/base #58185

Merged
merged 8 commits into from
Oct 23, 2023

Conversation

enkilee
Copy link
Contributor

@enkilee enkilee commented Oct 18, 2023

PR types

Others

PR changes

Others

Description

@paddle-bot
Copy link

paddle-bot bot commented Oct 18, 2023

你的PR提交成功,感谢你对开源项目的贡献!
请关注后续CI自动化测试结果,详情请参考Paddle-CI手册
Your PR has been submitted. Thanks for your contribution!
Please wait for the result of CI firstly. See Paddle CI Manual for details.

@paddle-bot paddle-bot bot added the contributor External developers label Oct 18, 2023
@luotao1 luotao1 added the HappyOpenSource 快乐开源活动issue与PR label Oct 18, 2023
@luotao1
Copy link
Contributor

luotao1 commented Oct 20, 2023

@gouzil 可以review了

@@ -42,7 +42,7 @@ class TestAssertVariable(Dy2StTestBase):
def _run(self, func, x, with_exception, to_static):
paddle.jit.enable_to_static(to_static)
if with_exception:
with self.assertRaises(BaseException):
with self.assertRaises(BaseException): # noqa: B017
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
with self.assertRaises(BaseException): # noqa: B017
with self.assertRaises(AssertionError):

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里从语义上来看,就是应该捕获各种异常的,noqa 是可以的,除非重构代码,不是传入 True/False 而是传入异常类型

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK

@@ -61,10 +61,10 @@ def test_max_memory_allocated_exception(self):
"gpu1",
]
for device in wrong_device:
with self.assertRaises(BaseException):
with self.assertRaises(BaseException): # noqa: B017
Copy link
Member

@gouzil gouzil Oct 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
with self.assertRaises(BaseException): # noqa: B017
with self.assertRaises((ValueError, AssertionError)):

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这四个 memory 的为什么是 ValueError, AssertionError 呢?这是能全部捕获的么?

@@ -61,10 +61,10 @@ def test_max_memory_reserved_exception(self):
"gpu1",
]
for device in wrong_device:
with self.assertRaises(BaseException):
with self.assertRaises(BaseException): # noqa: B017
Copy link
Member

@gouzil gouzil Oct 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
with self.assertRaises(BaseException): # noqa: B017
with self.assertRaises((ValueError, AssertionError)):

@@ -46,10 +46,10 @@ def test_memory_allocated_exception(self):
"gpu1",
]
for device in wrong_device:
with self.assertRaises(BaseException):
with self.assertRaises(BaseException): # noqa: B017
Copy link
Member

@gouzil gouzil Oct 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
with self.assertRaises(BaseException): # noqa: B017
with self.assertRaises((ValueError, AssertionError)):

@@ -46,10 +46,10 @@ def test_memory_reserved_exception(self):
"gpu1",
]
for device in wrong_device:
with self.assertRaises(BaseException):
with self.assertRaises(BaseException): # noqa: B017
Copy link
Member

@gouzil gouzil Oct 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
with self.assertRaises(BaseException): # noqa: B017
with self.assertRaises((ValueError, AssertionError)):

Copy link
Member

@gouzil gouzil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, @SigureMo

Copy link
Member

@SigureMo SigureMo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTMeow 🐾

@SigureMo SigureMo merged commit c460816 into PaddlePaddle:develop Oct 23, 2023
@enkilee enkilee deleted the codestyle-task3-Ruff-B017 branch December 19, 2023 05:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contributor External developers HappyOpenSource 快乐开源活动issue与PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants